/*
 * @Description: 第二十九章（express）
 * @Author: IA ia@kepro.space
 * @Date: 2025-02-27 18:24:54
 */
import express from 'express';
import type { Express, Request, Response} from 'express'

const app: Express = express()

    app.get('/router_study/login', (req:Request, res:Response) => {
        res.header("Access-Control-Allow-Origin", "*")
    if (req.query.user == 'admin' && req.query.password == '123') {
        res.json({
            route: [
                {
                    path: '/demo1',
                    name: 'Demo1',
                    component: 'demo1.vue'
                },
                {
                    path: '/demo2',
                    name: 'Demo2',
                    component: 'demo2.vue'
                },
                {
                    path: '/demo3',
                    name: 'Demo3',
                    component: 'demo3.vue'
                }
            ]
        })
    } else if (req.query.user == 'admin2' && req.query.password == '123') {
        res.json({
            route: [
                
                {
                    path: '/demo1',
                    name: 'Demo1',
                    component: 'demo1.vue'
                },
                {
                    path: '/demo2',
                    name: 'Demo2',
                    component: 'demo2.vue'
                }
            ]
        })
    } else {
        res.json({
            code: 400,
            message: '账号密码错误'
        })
    }
})


app.listen(9999, () => {
    console.log('Express app listen http://localhost:9999')
})